import 'package:flutter/material.dart';
import 'package:flutter_app_demo/podo/redux_demo_model.dart';
import 'package:flutter_app_demo/redux_demo/redux_demo.dart';

class ItemListWidget extends StatelessWidget {
    
    final ViewModel model;
    
    ItemListWidget(this.model);
    
    @override
    Widget build(BuildContext context) {
        // TODO: implement build
        return ListView(
            children: model.items.map(
                    (Item item) { // 这里匿名函数可以简写为 => 形式
                    return Row( //这里可以替换为 ListTile
                        children: <Widget>[
                            Text(item.body),
                            IconButton(
                                icon: Icon(Icons.delete),
                                onPressed: () => model.onRemoveItem(item),
                            ),
                        ],
                    );
                }
            ).toList(),
        );
    }
    
}

